#ifndef _H_SPE_FISH_H_
#define _H_SPE_FISH_H_

/* For struct Timer routines. */
#include <sys/time.h>
#include <time.h>

typedef struct {
  float x;
  float y;
  float vx;
  float vy;
  float ax;
  float ay;
  int pad[2]; // sum to 32bytes
} fish_t;

/* A simple wrapper around the clock() timer */
struct Timer {
  struct timeval clock_holder;
  struct timeval duration;
};

void initialize_timer (struct Timer* t);
void start_timer (struct Timer* t);
void stop_timer (struct Timer* t);
float timer_duration(const struct Timer t);


#define FISH_MASS ((float) 1.0)

#define LEFT_WALL ((float) (1.0))
#define RIGHT_WALL ((float) (2.0))
#define WALL_SEP (RIGHT_WALL - LEFT_WALL)


extern float min_r2; /* min_r squared */


/* The C99 fmax and fmin functions aren't defined on many platforms. */
#ifdef _AIX
#define inline __inline
#endif

static inline float
f_max (float a, float b)
{
  if (a > b) return a;
  if (b > a) return b;
#if defined(HAVE_ISNAN)
  if (isnan(a)) return b;
#else
  if (a != a) return b;
#endif
  return a;
}



#endif
